//
//  VideoPlayViewController.m
//  视频悬浮框OC
//
//  Created by 解楚豪 on 2018/9/10.
//  Copyright © 2018年 xch. All rights reserved.
//

#import "VideoPlayViewController.h"
#import <AVFoundation/AVFoundation.h>
#import <AVKit/AVKit.h>
#import "XCHVideoView.h"
#import "XCHPlay.h"

@interface VideoPlayViewController ()<AVPictureInPictureControllerDelegate>

@property (weak, nonatomic) IBOutlet UIView *playView;

@property (nonatomic, strong) AVPlayer *player;

@property (nonatomic, strong) AVPlayerLayer *playerLayer;

@property (nonatomic, strong) AVPictureInPictureController *pictureVC;

@property (nonatomic, strong) XCHVideoView *videoView;

@end

@implementation VideoPlayViewController

//-(void)loadView{
//    [super loadView];
//    _zView = [[ZVideoView alloc] initWithFrame:[UIScreen mainScreen].bounds];
//    self.view = _zView;
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self playVideo];
}

-(void)playVideo{
    _videoView = [[XCHVideoView alloc]initWithFrame:self.playView.bounds];
    _videoView.url = self.videoUrl;
    [self.playView addSubview:_videoView];
}

- (IBAction)backAction:(id)sender {
    if (self.backBlock) {
        self.backBlock();
    }
    
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)allOrSamllAction:(UIButton *)sender {
    sender.selected = !sender.selected;
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
